<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="easyUI/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="easyUI/themes/icon.css">
    <script type="text/javascript" src="easyUI/jquery.min.js"></script>
    <script type="text/javascript" src="easyUI/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="javaScript/iphost.js"></script>
</head>
<body style="text-align:center; background-color:#B7D2FF">
<h2 align="center">登录</h2>
<div style="margin:20px 0;"></div>
<div style="margin:0px auto;width:430px">
    <div class="easyui-panel" title="农资库存管理" style="width:100%;max-width:400px;padding:30px 60px;">
        <form id="ff" class="easyui-form" data-options="novalidate:true">
            <div style="margin-bottom:20px">
                <input id="inputaccount" class="easyui-textbox" name="schid" prompt="长度5-15位:" style="width:100%" data-options="label:'您的账号:',required:true,iconCls:'icon-man'">
            </div>
            <div style="margin-bottom:20px">
                <input id="inputpassword" class="easyui-passwordbox" name="password" prompt="密码应6-20位:" style="width:100%" data-options="label:'输入密码:',required:true,iconCls:'icon-lock'">
            </div>
        </form>
        <div style="text-align:center;padding:5px 0">
            <a id="submitform" href="javascript:void(0)" class="easyui-linkbutton" onclick="loginUser()" style="width:80px">登录</a>
        </div>
    </div>
</div>
</body>
<script>
    function loginUser() {
        $('#submitform').linkbutton('disable');
        var loginurl = ipAddress+"login";
        var accountvalue = document.getElementById("inputaccount").value;
        var passwordvalue = document.getElementById("inputpassword").value;
        var k = 0;
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: loginurl,
            data:{
                account : accountvalue,
                password : passwordvalue
            },
            success: function (data) {
                if(data.state == 1){
                    localStorage.setItem("userAccount",accountvalue);
                    localStorage.setItem("password",passwordvalue);
                    self.location = "homepage.html";
                }else{
                    $('#submitform').linkbutton('enable');
                    $.messager.show({
                        title:'提示',
                        msg: data.message,
                        timeout:1600,
                        showType:'slide'
                    });
                }
            },
            error: function (e) {
                $('#submitform').linkbutton('enable');
                alert("请检查输入信息是否合法，以及网络连接情况")
            }
        });
    }
</script>
</html>